home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / MM2_DEV / S / DEMO / DHRYSTON.ADA / D_GLOBAL.D next >
Encoding:
Text File  |  1990-12-01  |  16.5 KB  |  376 lines

  1. (*
  2.  ****************************************************************************
  3.  *
  4.  *                   "DHRYSTONE" Benchmark Program
  5.  *                   -----------------------------
  6.  *
  7.  *  Version:    Modula, Version 2.1
  8.  *
  9.  *  File:       d_global.def
  10.  *
  11.  *  Date:       June 8, 1989
  12.  *
  13.  *  Author:     Reinhold P. Weicker
  14.  *                      Siemens AG, E STE 35
  15.  *                      Postfach 3220
  16.  *                      8520 Erlangen
  17.  *                      Germany (West)
  18.  *                              Phone:  [xxx-49]-9131-7-20330
  19.  *                                      (8-17 Central European Time)
  20.  *                              Usenet: ..!mcvax!unido!estevax!weicker
  21.  *
  22.  *              Original Version (in Ada) published in
  23.  *              "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
  24.  *              pp. 1013 - 1030, together with the statistics
  25.  *              on which the distribution of statements etc. is based,
  26.  *
  27.  *              This version uses calls to the Pascal runtime library of the
  28.  *              Berkeley UNIX system (4.3 bsd) for time measurement.
  29.  *              For measurements on other systems, these calls need to be
  30.  *              modified.
  31.  *
  32.  *  Collection of Results:
  33.  *              Reinhold Weicker (address see above) and
  34.  *
  35.  *              Rick Richardson
  36.  *              PC Research. Inc.
  37.  *              94 Apple Orchard Drive
  38.  *              Tinton Falls, NJ 07724
  39.  *                      Phone:  (201) 834-1378 (9-17 EST)
  40.  *                      Usenet: ...!seismo!uunet!pcrat!rick
  41.  *
  42.  *      Please send results to Rick Richardson and/or Reinhold Weicker.
  43.  *      Complete information should be given on hardware and software used.
  44.  *      Hardware information includes: Machine type, CPU, type and size
  45.  *      of caches; for microprocessors: clock frequency, memory speed
  46.  *      (number of wait states).
  47.  *      Software information includes: Compiler (and runtime library)
  48.  *      manufacturer and version, compilation switches, OS version.
  49.  *      The Operating System version may give an indication about the
  50.  *      compiler; Dhrystone itself performs no OS calls in the measurement loop.
  51.  *
  52.  *      The complete output generated by the program should be mailed
  53.  *      such that at least some checks for correctness can be made.
  54.  *
  55.  ****************************************************************************
  56.  *
  57.  *  History:    This version Pascal/2.1 has been made for two reasons:
  58.  *
  59.  *              1) There is a need for a common Pascal version of
  60.  *              Dhrystone. Although translation from the published (Ada)
  61.  *              version to Pascal is straightforward in most aspects,
  62.  *              there are cases where it may not be obvious to everyone.
  63.  *              There should be, as far as possible, only one Pascal version
  64.  *              of Dhrystone such that results can be compared without
  65.  *              restrictions. Also, a Pascal version of Dhrystone has not yet
  66.  *              found a network distribution comparable to the C version
  67.  *              (version 1.1) distributed by Rick Richardson.
  68.  *
  69.  *              2) As far as it is possible without changes to the Dhrystone
  70.  *              statistics, optimizing compilers should be prevented from
  71.  *              removing significant statements.
  72.  *
  73.  *              This Pascal version 2.1 has been made consistent with the
  74.  *              C version 2.1; therefore the acknowledgments for the C version
  75.  *              are due for the Pascal version as well: I thank
  76.  *              Rick Richardson (Tinton Falls, NJ), Chaim Benedelac (Nat.
  77.  *              Semi.), David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
  78.  *              Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
  79.  *              for their help with comments on earlier versions of the
  80.  *              benchmark.
  81.  *
  82.  *  Changes:    In the initialization part, this version differs
  83.  *              from the Pascal version previously distributed by Reinhold
  84.  *              Weicker, the number of runs through Dhrystone is obtained
  85.  *              interactively from the terminal. Output of the result
  86.  *              has been changed to conform to the C version (2.1).
  87.  *              The changes in the initialization part and in the printing
  88.  *              of the result have no impact on performance measurement
  89.  *              since they are outside the measaurement loop.
  90.  *
  91.  *              Inside the measurement loop, this version follows the
  92.  *              version previously distributed by Reinhold Weicker.
  93.  *              As a correction to the published version, a statement
  94.  *              initializing Array2Glob [8,7] (outside the measurement
  95.  *              loop) has been added. Otherwise, this array element would
  96.  *              have an undefined value.
  97.  *
  98.  *              At several places in the benchmark, code has been added,
  99.  *              but within the measurement loop only in branches that
  100.  *              are not executed. The intention is that optimizing compilers
  101.  *              should be prevented from moving code out of the measurement
  102.  *              loop, or from removing code altogether. Since the statements
  103.  *              that are executed within the measurement loop have NOT been
  104.  *              changed, all numbers defining the "Dhrystone distribution"
  105.  *              (distribution of statements, operand types and locality)
  106.  *              still hold. Except for sophisticated optimizing compilers,
  107.  *              execution times for this version should be the same as
  108.  *              for previous versions.
  109.  *
  110.  *              Since it has proven difficult to subtract the time for the
  111.  *              measurement loop overhead in a correct way, the loop check
  112.  *              has been made a part of the benchmark. This does have
  113.  *              an impact - though a very minor one - on the distribution
  114.  *              statistics which have been updated for this version.
  115.  *
  116.  *              All changes within the measurement loop are described
  117.  *              and discussed in the companion paper "Rationale for
  118.  *              Dhrystone version 2".
  119.  *
  120.  *              Because of the self-imposed limitation that the order and
  121.  *              distribution of the executed statements should not be
  122.  *              changed, there are still cases where optimizing compilers
  123.  *              may not generate code for some statements. To a certain
  124.  *              degree, this is unavoidable for small synthetic benchmarks.
  125.  *              Users of the benchmark are advised to check code listings
  126.  *              whether code is generated for all statements of Dhrystone.
  127.  *
  128.  *              Version 2.1 is identical to version 2.0 distributed via
  129.  *              the UNIX network Usenet in March 1988 except that it corrects
  130.  *              some minor deficiencies that were found by users of version 2.0.
  131.  *              The only change within the measurement loop is that a
  132.  *              non-executed "else" part was added to the "if" statement in
  133.  *              Func3, and a non-executed "else" part removed from Proc3.
  134.  *
  135.  ***************************************************************************
  136.  *
  137.  *  Compilation model and measurement (IMPORTANT):
  138.  *
  139.  *  This program contains the Dhrystone program, including measurement setup,
  140.  *  in one file. The original (Ada) program contained three packages,
  141.  *  - a package with global type definitions,
  142.  *  - Pack_1, containing the main program (Proc_0 in Ada) and procedures
  143.  *            Proc_1, ... , Proc_5,
  144.  *  - Pack_2, containing Proc_6, ... , Proc_8, Func_1, ..., Func_3.
  145.  *  Since ISO/ANSI Standard Pascal provides no means to express separate
  146.  *  compilation (although many Pascal implementations provide such a feature),
  147.  *  it is not possible to formulate a portable Pascal version with the program
  148.  *  in several modules, corresponding more closely to the Ada and C versions.
  149.  *  Therefore, no attempt has been made to construct a Pascal version with
  150.  *  the program consisting of several modules.
  151.  *
  152.  *  This difference may impact execution time because the compiler can
  153.  *  perform more data flow analysis for a single-module program;
  154.  *  sophisticated compilers may be able to suppress code generation for
  155.  *  some parts of the program.
  156.  *  Users should check machine code listings generated by the compiler
  157.  *  to ensure that code is generated for all parts of the program.
  158.  *
  159.  *  The following "ground rules" apply for measurements:
  160.  *  - No procedure merging
  161.  *  - Otherwise, compiler optimizations are allowed but should be indicated
  162.  *  See the companion paper "Rationale for Dhrystone Version 2" for a more
  163.  *  detailed discussion of these ground rules.
  164.  *
  165.  *  For 16-Bit processors (e.g. 80x86), times for all compilation models
  166.  *  ("small", "medium", "large") should be given if possible, together
  167.  *  with a definition of these models for the compiler system used.
  168.  *
  169.  **************************************************************************
  170.  *
  171.  *  Dhrystone (Pascal version) statistics:
  172.  *
  173.  *  [Comment from the first distribution by Reinhold Weicker,
  174.  *   the distribution statistics have been updated for Version 2.1.
  175.  *   Note that because of language differences, the numbers are different
  176.  *   from the Ada version. The main difference is that the variables that
  177.  *   are local variables of "Proc_0" (Ada) or "main" (C) are global
  178.  *   variables in the Pascal version.]
  179.  *
  180.  *  The following program contains statements of a high level programming
  181.  *  language (here: Pascal) in a distribution considered representative:
  182.  *
  183.  *    assignments                  58
  184.  *    control statements           28
  185.  *    procedure, function calls    15
  186.  *
  187.  *  100 statements are dynamically executed. The program is balanced with
  188.  *  respect to the three aspects:
  189.  *
  190.  *    - statement type
  191.  *    - operand type (for simple data types)
  192.  *    - operand access
  193.  *         operand global, local, parameter, or constant.
  194.  *           There is no static nesting of blocks or procedures,
  195.  *           therefore all variables are either global or local.
  196.  *
  197.  *  The combination of these three aspects is balanced only approximately.
  198.  *
  199.  *  1. Statement Type:
  200.  *  -----------------             number
  201.  *
  202.  *     V1 := V2                   15
  203.  *     V := Constant              12
  204.  *       (incl. V1 := F(..)
  205.  *     Assignment,                 7
  206.  *       with array element
  207.  *     Assignment,                 6
  208.  *       with record component
  209.  *                                --
  210.  *                                40       40
  211.  *
  212.  *     X := Y +|-|and|or Z         5
  213.  *     X := Y +|-|"=" Constant     6
  214.  *     X := X +|- 1                3
  215.  *     X := Y *|/ Z                2
  216.  *     X := Expression,            1
  217.  *          two operators
  218.  *     X := Expression,            1
  219.  *          three operators
  220.  *                                --
  221.  *                                18       18
  222.  *
  223.  *     if .... then ....          14
  224.  *       with "else"      7
  225.  *       without "else"   7
  226.  *           executed        3
  227.  *           not executed    4
  228.  *     for I in 1..N do ...        7  |  counted every time
  229.  *     while ... do ...            4  |  the loop condition
  230.  *     repeat ... until            1  |  is evaluated
  231.  *     case ... end                1
  232.  *     with                        1
  233.  *                                --
  234.  *                                28       28
  235.  *
  236.  *     P (...)  procedure call    10
  237.  *     X := F (...)
  238.  *             function  call      5
  239.  *                                --
  240.  *                                15       15
  241.  *                                        ---
  242.  *                                        101
  243.  *
  244.  *    22 of the 58 assignments have a variable of a constrained
  245.  *    (sub-)type as their destination. In general, discriminant checks
  246.  *    will be necessary in these cases; however, the compiler may
  247.  *    optimize out some of these checks.
  248.  *
  249.  *    The average number of parameters in procedure or function calls
  250.  *    is 1.80 (not counting the function values as implicit parameters).
  251.  *
  252.  *
  253.  *  2. Operators
  254.  *  ------------
  255.  *                          number    approximate
  256.  *                                    percentage
  257.  *
  258.  *    Arithmetic             27          52.9
  259.  *
  260.  *       +                     16          31.4
  261.  *       -                      7          13.7
  262.  *       *                      3           5.9
  263.  *       div                    1           2.0
  264.  *
  265.  *    Comparison             20           39.2
  266.  *
  267.  *       =                      9           17.6
  268.  *       <>                     4            7.8
  269.  *       >                      1            2.0
  270.  *       <                      3            5.9
  271.  *       >=                     1            2.0
  272.  *       <=                     2            3.9
  273.  *
  274.  *    Logic                   4            7.8
  275.  *
  276.  *       AND                    1            2.0
  277.  *       OR                     1            2.0
  278.  *       NOT                    2            3.9
  279.  *
  280.  *                           --          -----
  281.  *                           51           99.9
  282.  *
  283.  *
  284.  *  3. Operand Type (counted once per operand reference):
  285.  *  ---------------
  286.  *                          number    approximate
  287.  *                                    percentage
  288.  *
  289.  *     Integer               135        54.7 %
  290.  *     Character              47        19.0 %
  291.  *     Enumeration            31        12.6 %
  292.  *     Boolean                13         5.3 %
  293.  *     Pointer                11         4.5 %
  294.  *     String30                6         2.4 %
  295.  *     Array                   2         0.8 %
  296.  *     Record                  2         0.8 %
  297.  *                           ---       -------
  298.  *                           247        100.1 %
  299.  *
  300.  *  When there is an access path leading to the final operand (e.g. a record
  301.  *  component), only the final data type on the access path is counted.
  302.  *
  303.  *  There are 16 accesses to components of a record, 9 of them go to
  304.  *  a component in a variant part. For some of these accesses, the
  305.  *  compiler may suppress generation of code checking the tag field
  306.  *  during optimization.
  307.  *
  308.  *
  309.  *  3. Operand Locality:
  310.  *  -------------------
  311.  *
  312.  *     local variable               84        34.0 %
  313.  *     global variable              58        23.5 %
  314.  *     parameter                    45        18.2 %
  315.  *        value                        23         9.3 %
  316.  *        reference                    22         8.9 %
  317.  *     function result               5         2.0 %
  318.  *     constant                     55        22.3 %
  319.  *                                 ---       -------
  320.  *                                 247       100.0 %
  321.  *
  322.  *
  323.  *  The program does not compute anything meaningful, but it is syntactically
  324.  *  and semantically correct. All variables have a value assigned to them
  325.  *  before they are used as a source operand.
  326.  *
  327.  *  There may be cases where a highly optimizing compiler may recognize
  328.  *  unnecessary statements and may not generate code for them.
  329.  *
  330.  *  There has been no explicit effort to account for the effects of a
  331.  *  cache, or to balance the use of long or short displacements for code or
  332.  *  data.
  333.  *
  334.  ****************************************************************************
  335.  *)
  336.  
  337.  
  338. DEFINITION MODULE D_Global;
  339.  
  340. TYPE
  341.  
  342.   (* Global type definitions *)
  343.  
  344.   Enumeration           = (Ident1, Ident2, Ident3, Ident4, Ident5);
  345.  
  346.   OneToThirty           = INTEGER [1..30];
  347.   OneToFifty            = INTEGER [1..50];
  348.   CapitalLetter         = CHAR ['A'..'Z'];
  349.  
  350.   String30              = ARRAY OneToThirty OF CHAR;
  351.  
  352.   Array1DimInteger      = ARRAY OneToFifty OF INTEGER;
  353.   Array2DimInteger      = ARRAY OneToFifty, OneToFifty OF INTEGER;
  354.  
  355.   RecordPointer         = POINTER TO RecordType;
  356.  
  357.   RecordType            =
  358.       RECORD
  359.         PointerComp:   RecordPointer;
  360.         CASE Discr:    Enumeration OF
  361.           Ident1:         (* only this variant is used,           *)
  362.                           (* but in some cases discriminant       *)
  363.                           (* checks are necessary                 *)
  364.              EnumComp:      Enumeration;
  365.              IntComp:       OneToFifty;
  366.              StringComp:    String30    |
  367.           Ident2:
  368.              Enum2Comp:    Enumeration;
  369.              String2Comp:  String30     |
  370.           Ident3, Ident4, Ident5:
  371.              Char1Comp,
  372.              Char2Comp:    CHAR
  373.         END; (* case *)
  374.       END; (* record *)
  375. END D_Global.
  376.